ostree-repo-traverse: Don't leak floating GVariant
authorAlexander Larsson <alexl@redhat.com>
Mon, 28 Nov 2016 14:31:04 +0000 (15:31 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Mon, 28 Nov 2016 14:53:50 +0000 (14:53 +0000)
ostree_object_name_serialize returns a floating ref, so we need
to sink it before putting in the hashtable.

Closes: #595
Approved by: cgwalters

src/libostree/ostree-repo-traverse.c

index e620a8ad9504319d381a5f4576a8f79106522de2..46f83240ab9658bd6953fc946a2c2d5685620af7 100644 (file)
@@ -348,7 +348,7 @@ traverse_iter (OstreeRepo                          *repo,
           ostree_repo_commit_traverse_iter_get_file (iter, &name, &checksum);
 
           g_debug ("Found file object %s", checksum);
-          key = ostree_object_name_serialize (checksum, OSTREE_OBJECT_TYPE_FILE);
+          key = g_variant_ref_sink (ostree_object_name_serialize (checksum, OSTREE_OBJECT_TYPE_FILE));
           g_hash_table_replace (inout_reachable, key, key);
           key = NULL;
         }
@@ -363,11 +363,11 @@ traverse_iter (OstreeRepo                          *repo,
 
           g_debug ("Found dirtree object %s", content_checksum);
           g_debug ("Found dirmeta object %s", meta_checksum);
-          key = ostree_object_name_serialize (meta_checksum, OSTREE_OBJECT_TYPE_DIR_META);
+          key = g_variant_ref_sink (ostree_object_name_serialize (meta_checksum, OSTREE_OBJECT_TYPE_DIR_META));
           g_hash_table_replace (inout_reachable, key, key);
           key = NULL;
 
-          key = ostree_object_name_serialize (content_checksum, OSTREE_OBJECT_TYPE_DIR_TREE);
+          key = g_variant_ref_sink (ostree_object_name_serialize (content_checksum, OSTREE_OBJECT_TYPE_DIR_TREE));
           if (!g_hash_table_lookup (inout_reachable, key))
             {
               g_hash_table_replace (inout_reachable, key, key);
@@ -463,7 +463,7 @@ ostree_repo_traverse_commit_union (OstreeRepo      *repo,
       OstreeRepoCommitState commitstate;
       gboolean ignore_missing_dirs = FALSE;
 
-      key = ostree_object_name_serialize (commit_checksum, OSTREE_OBJECT_TYPE_COMMIT);
+      key = g_variant_ref_sink (ostree_object_name_serialize (commit_checksum, OSTREE_OBJECT_TYPE_COMMIT));
 
       if (g_hash_table_contains (inout_reachable, key))
         break;